//
//  KKDatePicker.m
//  PhnixHome
//
//  Created by Levy Xu on 2018/1/8.
//  Copyright © 2018年 Levy Xu. All rights reserved.
//

#import "KKDatePicker.h"

@interface KKDatePicker ()

@end

@implementation KKDatePicker

- (void)didInitialized {
    [super didInitialized];
    
    BeginIgnoreAvailabilityWarning
    [self loadViewIfNeeded];
    EndIgnoreAvailabilityWarning
}

- (void)initSubviews {
    [super initSubviews];
    
    self.datePicker = [[UIDatePicker alloc] init];
    [self.view addSubview:self.datePicker];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    self.datePicker.frame = CGRectMake(0, CGRectGetMaxY(self.headerView.frame), CGRectGetWidth(self.view.bounds), (!self.footerView.hidden ? CGRectGetMinY(self.footerView.frame) : CGRectGetHeight(self.view.bounds)) - CGRectGetMaxY(self.headerView.frame));
}

#pragma mark - <QMUIModalPresentationContentViewControllerProtocol>
- (CGSize)preferredContentSizeInModalPresentationViewController:(QMUIModalPresentationViewController *)controller limitSize:(CGSize)limitSize {
    CGFloat datePickerHeight = 216;
    return CGSizeMake(limitSize.width, CGRectGetHeight(self.headerView.frame) + datePickerHeight + (!self.footerView.hidden ?  CGRectGetHeight(self.footerView.frame) : 0));
}
@end
